package LeetCode;

/**
 * @Author: Dijah
 * @Date: 2023/4/7 13:04
 * @Desc: 盛最多水的容器
 * https://leetcode.cn/problems/container-with-most-water/
 */
public class code11_maxArea {

    public int maxArea(int[] height){
        //找右侧比左侧的大的
        int res = 0;
        int left = 0;
        int right = height.length - 1;
        while (left < right){
            res = Math.max(res,(right - left) * Math.min(height[left],height[right]));
            if(height[left] > height[right]){
                right--;
            }else{
                left++;
            }
        }
        return res;
    }
}
